<?php
/**
 * @version		$Id: helper.php 258 2012-03-09 13:32:55Z ercanozkaya $
 * @category	DOCmanPopulate
 * @package		DOCmanPopulate15
 * @copyright	Copyright (C) 2003 - 2010 Johan Janssens and Mathias Verraes. All rights reserved.
 * @license		GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
 * @link     	http://www.joomladocman.org
 */
defined('_JEXEC') or die('Restricted access');

class PopulateInstallHelper
{
    public static function logo()
    {

    	?><br />
        <table>
            <tr>
                <th>
				  <a href='index.php?option=com_populate&view=config'><img border="0" alt="DOCman" src="<?php echo JURI::root(0)?>/administrator/components/com_docman/images/dm_logo.png" /></a>
                </th>
            </tr>
        </table><?php
    }

    public static function config()
    {
    	$db = JFactory::getDBO();
    	$db->setQuery('SELECT COUNT(*) FROM #__populate_conf');
    	if(!$db->loadResult())
    	{
			$query = "INSERT INTO `#__populate_conf` (
				`id` , `skipfiles` , `dmdescription` ,
				`published` , `approved` , `dmthumbnail` ,
				`dmlicense_id` , `dmlicense_display` , `dmmantainedby` ,
				`dmlastupdateby` , `dmsubmitedby` , `dmowner` ,
				`dmurl` , `access` , `attribs`,
				`stripextension`, `orphansonly`, `nicetitle`, `password` ,
				`catid`, `usefiletime`  )
				VALUES ('1', '.|..|.htaccess|index.php|index.htm|index.html', '',
				'0', '1', NULL ,
				NULL , '0', '-1' ,
				NULL , NULL , '0' ,
				'' , '0', '',
				'1', '1', '1', '', '0', '0' );";
			$db->setQuery($query);
			$db->query();
    	}
    }

    public static function getInfo()
    {
    	$db = JFactory::getDBO();
    	$version = new JVersion();

        $info = array(
    		'ext'	=> 'Populate',
    		'v'		=> '1.5.2',
    		'up'	=> 'unknown',
    		'cms'	=> $version->PRODUCT.' '.$version->RELEASE .'.'. $version->DEV_LEVEL,
    	    'k'		=> class_exists('Koowa') &&  method_exists('Koowa', 'getVersion') ? Koowa::getVersion() : 0,
    		'p' 	=> phpversion(),
    		'db'	=> $db->getVersion(),
    	);
    	return http_build_query($info);

    }
}
